#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[100];
int b[100];
int c[100];
int d[100];
int total;
void getin() {
	cin >> n;
}
void dfs(int i) {
	if (i > n) {
		total++;
		return;
	}
	for (int j = 1; j <= n; j++) {
		if (b[j] == 0 && c[i + j] == 0 && d[i - j + n] == 0) {
			a[i] = j;
			b[j] = 1;
			c[i + j] = 1;
			d[i - j + n] = 1;
			dfs(i + 1);
			b[j] = 0;
			c[i + j] = 0;
			d[i - j + n] = 0;
		}
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	getin();
	dfs(1);
	cout << total;
	return 0;
}
